<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>上传</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../static/layui/css/layui.css" media="all">
<!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

	<fieldset class="layui-elem-field layui-field-title"
		style="margin-top: 20px;">
		<legend>投稿</legend>
	</fieldset>
	<div class="layui-bg-gray">


		<!-- <form id="uploadJS" action="ajaxuser.do?op=login" method="post"> -->
		<div class="layui-form-item">
			<label class="layui-form-label">标题</label>
			<div class="layui-input-inline">
				<input id="titletext" type="text" name="username"
					lay-verify="required" placeholder="请输入" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">简介</label>
			<div class="layui-input-inline">
				<input id="synopsis" type="text" name="username"
					lay-verify="required" placeholder="请输入" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		
<form class="layui-form" action="">		
<div class="layui-form-item">
<div class="layui-inline">
      <label class="layui-form-label">搜索选择框</label>
      <div class="layui-input-inline">
        <select id = "select" name="modules" lay-verify="required">
          <option value="">直接选择或搜索类型分区</option>
          <option value="TV剧">TV剧</option>
		  <option value="专栏">专栏</option>
          <option value="动画">动画</option>
          <option value="国创">国创</option>
          <option value="娱乐">娱乐</option>
          <option value="广告">广告</option>
          <option value="影视">影视</option>
          <option value="数码">数码</option>
          <option value="时尚">时尚</option>
          <option value="游戏">游戏</option>
          <option value="漫画">漫画</option>
          <option value="生活">生活</option>
          <option value="电影">电影</option>
          <option value="番剧">番剧</option>
          <option value="直播">直播</option>
          <option value="科技">科技</option>
          <option value="纪录片">纪录片</option>
          <option value="老李">老李</option>
          <option value="舞蹈">舞蹈</option>
          <option value="音乐">音乐</option>
          <option value="鬼畜">鬼畜</option>
        </select>
      </div>
    </div>
    </div>
   </form>

		<!-- </form> -->


		<fieldset class="layui-elem-field layui-field-title"
			style="margin-top: 30px;">
			<legend>封面上传</legend>
		</fieldset>

		<div class="layui-upload">
			<button type="button"
				class="layui-btn layui-btn-normal layui-btn-radius" id="img">上传图片</button>
			<div class="layui-upload-list">
				<img class="layui-upload-img" id="demo1">
				<p id="demoText"></p>
			</div>
		</div>
		<fieldset class="layui-elem-field layui-field-title"
			style="margin-top: 30px;">
			<legend>投稿视频上传</legend>
		</fieldset>

		<div class="layui-upload">
			<button type="button"
				class="layui-btn layui-btn-normal layui-btn-radius" id="test8">上传视频</button>
			<br> <br> <br>
	
			
			
			<button type="button" class="layui-btn layui-btn-radius" id="test9">提交投稿</button>
		</div>
	</div>
	<script src="../static/layui/layui.all.js" charset="utf-8"></script>
	<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
	<script>
		var $ = layui.jquery, upload = layui.upload;
		//普通图片上传
		var uploadInst = upload.render({
			elem : '#img',
			url : '../ups.do?op=ima' //改成您自己的上传接口
			,
			accept : 'images',
			choose : function(obj) {
				obj.preview(function(index, file, result) {
					$('#demo1').attr('src', result); // 图片链接（base64）
				});
			},
			before : function(obj) {
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result) {
					$('#demo1').attr('src', result); //图片链接（base64）
				});
			},
			done : function(res) {
				//如果上传失败
				if (res.code > 0) {
					return layer.msg(res);
				} else {
					return layer.msg('封面上传成功');
				}
				//上传成功
			}
		});

		//选完文件后不自动上传
		upload.render({
			elem : '#test8',
			url : '../ups.do?op=videoU' //改成您自己的上传接口
			,
			auto : false
			//,multiple: true
			,
			accept : 'video' //视频
			,
			bindAction : '#test9',
			before : function(obj) {
				this.data = {
					'title' : $("#titletext").val(),
					'synopsis' : $('#synopsis').val(),
					'type' : $("#select").val()
				};
				console.log("select" + $("#select").val());
				console.log("title" + $("#titletext").val());
				console.log("synopsis" + $('#synopsis').val);

			},
			done : function(res) {
				if (res.code > 0) {
					return layer.msg(res);
				} else {
					return layer.msg('投稿成功');
				}
			}
		});
		
		

	</script>

	<!-- 	<script>
		var $ = layui.$ //重点处
		, layer = layui.layer;
		$("#test9").click(function() {
			let title = $('#titletext').val;
			let synopsis = $('#jianjietext').val;
			console.log(title);
			console.log(synopsis);
			$.ajax({
				url : '../ups.do?op=videoU&',//后台控制器
				type : 'post',
				dataType : 'json',
				before : function(obj) {
					this.data = {
						'title' : $('#titletext').val
					};
					console.log(res);
				},
				done : function(res) {

					if (res.code == 0) {

						layer.msg(res.msg);

					} else {

						layer.msg(res.msg);

					}

				}
			});
		});
	</script>
 -->


</body>
</html>